/**
 * 
 */
package com.media.module.view;

import com.media.module.utils.ActivityStyle;
import com.media.module.utils.DimenValues;
import com.media.module.utils.MResource;
import com.media.module.utils.UIGlobalDef;
import com.media.module.widget.CircleImageView;
import com.media.module.widget.RoundProgressBar;

import android.content.Context;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

/**
 * TODO
 * 
 * @author zhyc 2016年7月24日下午4:06:21 FooterView.java
 */
public class FooterView extends LinearLayout {

	private Context mContext;
	
	public FooterView(Context context) {
		super(context);
		mContext = context;
		onCreateView();
	}

	private void onCreateView() {
		DisplayMetrics dMetrics = mContext.getResources().getDisplayMetrics();
		float lfbaseDim = MResource.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DimenValues.BASE_VALUE, dMetrics);
		// Left Tab
		RelativeLayout llayoutLeft = new RelativeLayout(mContext);
		llayoutLeft.setLayoutParams(ActivityStyle.getTibStyleParams());
		addView(llayoutLeft);
		
		// Middle Tab
		RelativeLayout llayoutMid = new RelativeLayout(mContext);

		RoundProgressBar lProgressBarTime = new RoundProgressBar(mContext);
		lProgressBarTime.setId(UIGlobalDef.VIEW_ID.ROUND_PROGRESS_BAR);
		lProgressBarTime.setLayoutParams(ActivityStyle.getImageButtonLayoutParams(lfbaseDim));
		llayoutMid.addView(lProgressBarTime);

		ImageView ivMid = new ImageView(mContext);
		ivMid.setImageDrawable(MResource.getDrawableFromAssets(mContext, "btn_shutter_video_normal.png"));
		ivMid.setLayoutParams(ActivityStyle.getImageButtonLayoutParams(lfbaseDim / 4));
		llayoutMid.addView(ivMid);

		ImageView livStart = new ImageView(mContext);
		livStart.setId(UIGlobalDef.VIEW_ID.RECORD_MEDIA_START);
		String[] strStart = { "btn_shutter_video_normal.png", "btn_shutter_video_press.png" };
		livStart.setImageDrawable(MResource.getSelectorDrawable(mContext, strStart));
		livStart.setLayoutParams(ActivityStyle.getImageButtonLayoutParams(lfbaseDim));
		llayoutMid.addView(livStart);

		ImageView livStop = new ImageView(mContext);
		livStop.setId(UIGlobalDef.VIEW_ID.RECORD_MEDIA_STOP);
		String[] strStop = { "btn_shutter_video_stop.png", "btn_shutter_video_stop_press.png" };
		livStop.setImageDrawable(MResource.getSelectorDrawable(mContext, strStop));
//		livStop.setBackground(MResource.getDrawableFromAssets(mContext, "btn_shutter_circle_animation.png"));
		livStop.setVisibility(View.GONE);
		livStop.setLayoutParams(ActivityStyle.getImageButtonLayoutParams(lfbaseDim));
		llayoutMid.addView(livStop);
		addView(llayoutMid, ActivityStyle.getTibStyleParams());

		// Right Tab
		RelativeLayout llayoutRight = new RelativeLayout(mContext);

		CircleImageView livPlay = new CircleImageView(mContext);
		livPlay.setId(UIGlobalDef.VIEW_ID.MEDIA_PREVIEW);
		livPlay.setLayoutParams(ActivityStyle.getImageButtonLayoutParams(lfbaseDim / 4 * 3));
		llayoutRight.addView(livPlay);
		livPlay.setVisibility(View.GONE);

		ImageView livPause = new ImageView(mContext);
		livPause.setId(UIGlobalDef.VIEW_ID.RECORD_MEDIA_PAUSE);
		String[] strPause = { "ic_btn_pause_in_video.png", "ic_btn_pause_in_video_pressed.png" };
		livPause.setImageDrawable(MResource.getSelectorDrawable(mContext, strPause));
		livPause.setLayoutParams(ActivityStyle.getImageButtonLayoutParams(lfbaseDim / 4 * 3));
		livPause.setVisibility(View.GONE);
		llayoutRight.addView(livPause);

		ImageView livResume = new ImageView(mContext);
		livResume.setId(UIGlobalDef.VIEW_ID.RECORD_MEDIA_RESUME);
		String[] strResume = { "ic_btn_resume_in_video.png", "ic_btn_resume_in_video_pressed.png" };
		livResume.setImageDrawable(MResource.getSelectorDrawable(mContext, strResume));
		livResume.setLayoutParams(ActivityStyle.getImageButtonLayoutParams(lfbaseDim / 4 * 3));
		livResume.setVisibility(View.GONE);
		llayoutRight.addView(livResume);

		addView(llayoutRight, ActivityStyle.getTibStyleParams());
	}
}
